package response

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"syuee.com/iShot/dto"
)

func Response(ctx *gin.Context, httpStatus int, data gin.H, code int, msg string) {
	meta := gin.H{"msg": msg, "status": code}
	ctx.JSONP(httpStatus, gin.H{"data": data, "meta": meta})
}
func ResponseToken(ctx *gin.Context, httpStatus int, datatoken dto.UserDtoToken, code int, msg string) {
	meta := gin.H{"msg": msg, "status": code}
	ctx.JSONP(httpStatus, gin.H{"data": datatoken, "meta": meta})
}
func ResponseUser(ctx *gin.Context, httpStatus int, datauser dto.UserDto, code int, msg string) {
	meta := gin.H{"msg": msg, "status": code}
	ctx.JSONP(httpStatus, gin.H{"data": datauser, "meta": meta})
}

func Success(ctx *gin.Context, data gin.H, msg string) {
	Response(ctx, http.StatusOK, data, 200, msg)
}
func SuccessToken(ctx *gin.Context, datatoken dto.UserDtoToken, msg string) {
	ResponseToken(ctx, http.StatusOK, datatoken, 200, msg)
}

func SuccessUser(ctx *gin.Context, datauser dto.UserDto, msg string) {
	ResponseUser(ctx, http.StatusOK, datauser, 200, msg)
}





func Fail(ctx *gin.Context, msg string, data gin.H) {
	Response(ctx, http.StatusOK, data, 400, msg)
}
